


/**
 * 模块依赖
 */
var db = require("../lib/db");

//查找记录
exports.select = function(userid, handler) {
    db.execQuery({
        "sql": "SELECT * FROM operlog WHERE userid=? order by operdate desc",
        "args": [userid],
        "handler": handler
    });
};




//插入
exports.insert = function(operlogdata, handler) {
    db.execQuery({
        "sql": "insert into operlog " +
            "(userid,username,nickname,opertype,opercont,operip,operdate) values (?,?,?,?,?,?,now())",
        "args":[
            operlogdata.userid,
            operlogdata.username,
            operlogdata.nickname,
            operlogdata.opertype,
            operlogdata.opercont,
            operlogdata.operip
        ],
        "handler": handler
    });
};


exports.delete = function(id, handler) {
    db.execQuery({
        "sql": "delete from  operlog  where id in (?) ",
        "args":[id],
        "handler": handler
    });
};

exports.deleteAll = function(id, handler) {
    db.execQuery({
        "sql": "delete from  operlog  where userid = ? ",
        "args":[id],
        "handler": handler
    });
};
//遍历记录
exports.selectAll = function(handler) {
    db.execQuery({
        "sql": "SELECT * FROM operlog ORDER BY operdate desc,id asc",
        "handler": handler
    });
};
